import Vue from 'vue'
import Vuex from 'vuex'

import permission from './permission'
import user from './user'


Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tagList: [],
    isCollapse: eval(localStorage.getItem('isCollapse')) || false, //是否隐藏左侧菜单栏
  },
  mutations: {
    setIsCollapse (state, collapse) {
      localStorage.setItem('isCollapse', collapse)
      state.isCollapse = collapse
    },
    // 添加页面标签
    addTagList (state, tagItem) {
      const tagSome = state.tagList.some(tag => tag.name == tagItem.name)
      if (!tagSome) state.tagList.push(tagItem)
    },
    // 重新赋值页面标签
    setTagList (state, TagList) {
      state.tagList = TagList
    },
  },

  modules: {
    permission,
    user
  }
})



